﻿#include "opencv2\opencv.hpp"
using namespace cv;

int main()
{
	const char* fn = "D:\\opencv class\\lena.jpg";
	Mat image = imread(fn);
	imshow("原始图像", image);


	Mat gray_image;
	cvtColor(image, gray_image, COLOR_BGR2GRAY);
	imshow("灰度图", gray_image);
	/* Sobel 算子边缘检测 */
	Mat sobel_image1, sobel_image2;
	Sobel(gray_image, sobel_image1, CV_8U, 1, 1, 3, 2);
	imshow("黑白Sobel", sobel_image1);

	Sobel(image, sobel_image2, CV_8U, 1, 1);
	imshow("彩色Sobel", sobel_image2);

	/*Canny 算子边缘检测*/
	Mat canny_image;
	Canny(gray_image, canny_image, 100, 200);
	imshow("Canny", canny_image);
	waitKey(0);

}